package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.ActionRecord;
import com.ruoyi.ring.service.IActionRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 行动Controller
 * 
 * @author liuwp
 * @date 2025-08-20
 */
@RestController
@RequestMapping("/ring/action_record")
public class ActionRecordController extends BaseController
{
    @Resource
    private IActionRecordService actionRecordService;

    /**
     * 查询行动列表
     */
    @PreAuthorize("@ss.hasPermi('ring:action_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActionRecord actionRecord)
    {
        startPage();
        List<ActionRecord> list = actionRecordService.selectActionRecordList(actionRecord);
        return getDataTable(list);
    }

    /**
     * 导出行动列表
     */
    @PreAuthorize("@ss.hasPermi('ring:action_record:export')")
    @Log(title = "行动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActionRecord actionRecord)
    {
        List<ActionRecord> list = actionRecordService.selectActionRecordList(actionRecord);
        ExcelUtil<ActionRecord> util = new ExcelUtil<ActionRecord>(ActionRecord.class);
        util.exportExcel(response, list, "行动数据");
    }

    /**
     * 获取行动详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:action_record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(actionRecordService.selectActionRecordById(id));
    }

    /**
     * 新增行动
     */
    @PreAuthorize("@ss.hasPermi('ring:action_record:add')")
    @Log(title = "行动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActionRecord actionRecord)
    {
        return toAjax(actionRecordService.insertActionRecord(actionRecord));
    }

    /**
     * 修改行动
     */
    @PreAuthorize("@ss.hasPermi('ring:action_record:edit')")
    @Log(title = "行动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActionRecord actionRecord)
    {
        return toAjax(actionRecordService.updateActionRecord(actionRecord));
    }

    /**
     * 删除行动
     */
    @PreAuthorize("@ss.hasPermi('ring:action_record:remove')")
    @Log(title = "行动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(actionRecordService.deleteActionRecordByIds(ids));
    }

}
